package org.csu.molediary.api.controller.front;

import org.csu.molediary.api.common.CommonResponse;
import org.csu.molediary.api.entity.Account;
import org.csu.molediary.api.service.FriendService;
import org.csu.molediary.api.vo.FriendVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/friend/")
public class FriendController {

    @Autowired
    private FriendService friendService;

    @GetMapping("allfriend/{me}")
    @ResponseBody
    //获取某用户所有好友
    public CommonResponse<List<FriendVO>> getAllFriendByMe(@PathVariable String me){
        return friendService.getAllFriendByMe(me);
    }

    @PostMapping("addfriend")
    @ResponseBody
    //添加好友,这里每添加一个好友要添加两条
    public CommonResponse<FriendVO> addFriendById(@RequestParam String me,@RequestParam String mefriend){
        return friendService.addFriendById(me,mefriend);
    }

    @GetMapping("selectfriend")
    @ResponseBody
    //通过name模糊查询好友
    public CommonResponse<List<Account>> getFriendByNameLike(@RequestParam String me, @RequestParam String namelike){
        return null;
    }

}
